package br.com.automed.entity;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

import org.hibernate.annotations.GenericGenerator;

@NamedQueries({
	@NamedQuery(name="verificaMatricula", query="FROM MatriculaValida m WHERE m.matricula = :matricula")
})
@Entity
@Table(name="CM_MATRICULA_CONVENIO")
public class MatriculaValida {
	
	public static final String NAMED_QUERY_VERIFICA_MATRICULA = "verificaMatricula";
	
	@Id
    @GeneratedValue(generator = "system-uuid", strategy=GenerationType.AUTO)
    @GenericGenerator(name = "system-uuid", strategy = "uuid")
    @Column(name = "ID_MATRICULA_CONVENIO")
	private String idMatriculaValida;
	
	@Column(name = "ST_MATRICULA")
	private String matricula;
	
	@Column(name = "FLAG_ATIVO")
	private String flagAtivo;

	@ManyToOne()
	@JoinColumn(name="FK_CONVENIO", referencedColumnName="ID_CONVENIO")
	private Convenio convenio;

	public String getIdMatriculaValida() {
		return idMatriculaValida;
	}

	public void setIdMatriculaValida(String idMatriculaValida) {
		this.idMatriculaValida = idMatriculaValida;
	}

	public String getMatricula() {
		return matricula;
	}

	public void setMatricula(String matricula) {
		this.matricula = matricula;
	}

	public String getFlagAtivo() {
		return flagAtivo;
	}

	public void setFlagAtivo(String flagAtivo) {
		this.flagAtivo = flagAtivo;
	}

	public Convenio getConvenio() {
		return convenio;
	}

	public void setConvenio(Convenio convenio) {
		this.convenio = convenio;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime
				* result
				+ ((idMatriculaValida == null) ? 0 : idMatriculaValida
						.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		MatriculaValida other = (MatriculaValida) obj;
		if (idMatriculaValida == null) {
			if (other.idMatriculaValida != null)
				return false;
		} else if (!idMatriculaValida.equals(other.idMatriculaValida))
			return false;
		return true;
	}

}
